<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单事件</title>
</head>
<body>
    <input type="password" name="password" value=""> 
    <button onclick="getPWD()">密码是多少</button>
    <script>
      function getPWD(){
         let pwd = document.getElementsByName('password');
         console.log(pwd[0].value);
      }
    </script>
    男<input type="radio" value="男" name="gender" checked>
    女<input type="radio" value="女" name="gender">
    <button onclick="gender()">按钮</button>
    <script>
        //获得选中性别的值
       function gender(){
        let gen = document.getElementsByName('gender')
        for(let i= 0;i<gen.length;i++){
            if(gen[i].checked){
                console.log(gen[i]);
                
            }
        }
       }
    </script>
    足球<input type="checkbox" name="join" value="足球">
    排球<input type="checkbox" name="join" value="足球">
    篮球<input type="checkbox" name="join" value="足球">
    <button onclick="check()">按钮</button>
    <script>
        function check(){
            let arr = new Array();
            let ch = document.getElementsByName('join')
            for(let i = 0;i<ch.length;i++){
              if(ch[i].checked){
                arr.push(ch[i].value)
              }
            }
       
        console.log(arr);
         }
    </script>
    <hr>
    <select name="car" onchange="getcar()">
        <option value="DZ">大众</option>
        <option value="BM">宝马</option>
        <option value="BC">奔驰</option>
       
        <script>
            function getcar(){
                let car = document.getElementsByName('car')
                console.log(car[0].value);
                
            }
        </script>

    </select>
</body>
</html>